<template>
  <div>
    <el-row>
      <el-table
          fixed
          :data="tableData"
          style="width: 100%">
        <el-table-column
            fixed
            type="index"
            label="序号"
            width="100">
        </el-table-column>
        <el-table-column
            prop="orderNumber"
            label="订单号"
            width="320">
        </el-table-column>
        <el-table-column
            prop="orderName"
            label="收件人"
            width="120">
        </el-table-column>

        <el-table-column
            prop="orderPhone"
            label="收件人手机号"
            width="240">
        </el-table-column>

        <el-table-column
            prop="orderAddress"
            label="详细地址"
            width="600">
        </el-table-column>

        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
                size="mini"
                type="danger"
                @click="del(scope.$index)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-row>

  </div>
</template>

<script>
export default {
  name: "AOrder",
  data() {
    return {
      tableData: [],
      formLabelWidth:'120px'
    }
  },
  methods:{
    getAllOrder() {
      this.$axios.get("/order/getall").then(res => {
        if(res.data.code == 0) {
          this.tableData = res.data.data
          this.$message.success("获取成功")
        } else {
          this.$message.error(res.data.message)
        }
      })
    },
    del(index) {
      this.$axios.post("/order/delete",this.tableData[index]).then(res => {
        if(res.data.code == 0) {
          this.$message.success("删除成功")
          location.reload()
        } else {
          this.$message.error(res.data.message)
        }
      })
    }
  },
  created() {
    this.getAllOrder()
  }
}
</script>

<style scoped>

</style>